package com.chaosj.memory.command;

import com.chaosj.webmagic.DefaultLocalFileService;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.shell.standard.ShellComponent;
import org.springframework.shell.standard.ShellMethod;
import org.springframework.shell.standard.ShellOption;

/**
 * @className: ScrapeWxCommand
 * @description:
 * @author: caoyangjie
 * @date: 2022/3/22
 **/
@ShellComponent
public class ScrapeWxCommand extends AbstractCommand{
    @Value("${path.scrape:/home/ubuntu/scrape}")
    private String basePath;

    @ShellMethod("pack url isArticle maxDepth")
    public String pack(
                     @ShellOption(help = "待爬取的文件uri地址") String scrapeUri,
                     @ShellOption(help = "是否爬取系列文章: true | false") String isArticle,
                     @ShellOption(help = "递归爬取最大深度") String maxDepth) {
        DefaultLocalFileService.set(basePath);
        String[] args = new String[]{"pack", scrapeUri, isArticle, maxDepth};
        return defaultInvoke(args);
    }
}
